﻿using System;
using Super_Management_Mayhem.Content.Animations.Manager;
using Super_Management_Mayhem.Content.Spritesheet.Player;
using Transformable_Engine_v2.Engine.Animation.FrameAnimation;
using Transformable_Engine_v2.Engine.GameObjects.Containers;
using Transformable_Engine_v2.Engine.Graphics;
using Transformable_Engine_v2.Engine.Transformable_Math.Geometry;

namespace Super_Management_Mayhem.Screens.Playing.Players.Manager
{
    public partial class Manager
    {
        protected virtual string SpriteSheetPath
        {
            get
            {
                return new ManagerSheet().SpriteSheetPath;
            }
        }

        protected virtual float WalkSpeed
        {
            get
            {
                return 10;
            }
        }

        public virtual ImageContainer GetFaceIndicator()
        {
            return new ImageContainer {
                                          Sprite = SpriteSheet.GetSprite(SpriteSheetPath, ManagerSheet.Indicator.FaceIndicator),
                                          Origin = TE_Rectangle.Alignment.CenterMiddle,
                                          Scale = new TE_Vector2(2, 2)
                                      };
        }

        protected virtual double GetAttackTime(Direction direction)
        {
            switch (direction)
            {
                case Direction.Up:
                    return AttackUpState.Duration;
                case Direction.Down:
                    return AttackDownState.Duration;
                case Direction.Left:
                    return AttackLeftState.Duration;
                case Direction.Right:
                    return AttackRightState.Duration;
            }

            return -1;
        }

        protected virtual void SetAttackModel(Direction direction)
        {
            switch (direction)
            {
                case Direction.Up:
                    _character.OriginAbsolute = new TE_Vector2(24, 31);
                    _character.AddAnimations(new FrameAnimation(new AttackUpState(SpriteSheetPath)));
                    break;
                case Direction.Down:
                    _character.OriginAbsolute = new TE_Vector2(13, 21);
                    _character.AddAnimations(new FrameAnimation(new AttackDownState(SpriteSheetPath)));
                    break;
                case Direction.Left:
                    _character.OriginAbsolute = new TE_Vector2(24, 31);
                    _character.AddAnimations(new FrameAnimation(new AttackLeftState(SpriteSheetPath)));
                    break;
                case Direction.Right:
                    _character.OriginAbsolute = new TE_Vector2(8, 31);
                    _character.AddAnimations(new FrameAnimation(new AttackRightState(SpriteSheetPath)));
                    break;
            }
        }

        protected virtual void SetFallModel()
        {
            _character.AddAnimations(new FrameAnimation(new Fall(SpriteSheetPath)));
            _character.OriginAbsolute = new TE_Vector2(12, 31);
        }

        protected virtual void SetIdleCarryModel(Direction direction)
        {
            switch (direction)
            {
                case Direction.Up:
                    _character.Sprite = SpriteSheet.GetSprite(SpriteSheetPath, ManagerSheet.PickupUpState.PickupUp);
                    break;
                case Direction.Down:
                    _character.Sprite = SpriteSheet.GetSprite(SpriteSheetPath, ManagerSheet.PickupDownState.PickupDown);
                    break;
                case Direction.Left:
                    _character.Sprite = SpriteSheet.GetSprite(SpriteSheetPath, ManagerSheet.PickupLeftState.PickupLeft);
                    break;
                case Direction.Right:
                    _character.Sprite = SpriteSheet.GetSprite(SpriteSheetPath, ManagerSheet.PickupRightState.PickupRight);
                    break;
            }
            _character.OriginAbsolute = new TE_Vector2(12, 31);
        }

        protected virtual void SetIdleModel(Direction direction)
        {
            switch (direction)
            {
                case Direction.Up:
                    _character.Sprite = SpriteSheet.GetSprite(SpriteSheetPath, ManagerSheet.IdleState.Up);
                    break;
                case Direction.Down:
                    _character.Sprite = SpriteSheet.GetSprite(SpriteSheetPath, ManagerSheet.IdleState.Down);
                    break;
                case Direction.Left:
                    _character.Sprite = SpriteSheet.GetSprite(SpriteSheetPath, ManagerSheet.IdleState.Left);
                    break;
                case Direction.Right:
                    _character.Sprite = SpriteSheet.GetSprite(SpriteSheetPath, ManagerSheet.IdleState.Right);
                    break;
            }

            _character.OriginAbsolute = new TE_Vector2(8, 31);
        }

        protected virtual void SetWalkCarryModel(Direction direction)
        {
            switch (direction)
            {
                case Direction.Up:
                    _character.OriginAbsolute = new TE_Vector2(12, 31);
                    _character.AddAnimations(new FrameAnimation(new WalkUpCarry(SpriteSheetPath)));
                    break;
                case Direction.Down:
                    _character.OriginAbsolute = new TE_Vector2(12, 31);
                    _character.AddAnimations(new FrameAnimation(new WalkDownCarry(SpriteSheetPath)));
                    break;
                case Direction.Left:
                    _character.OriginAbsolute = new TE_Vector2(8, 31);
                    _character.AddAnimations(new FrameAnimation(new WalkLeftCarry(SpriteSheetPath)));
                    break;
                case Direction.Right:
                    _character.OriginAbsolute = new TE_Vector2(8, 31);
                    _character.AddAnimations(new FrameAnimation(new WalkRightCarry(SpriteSheetPath)));
                    break;
            }
        }

        protected virtual void SetWalkModel(Direction direction)
        {
            switch (direction)
            {
                case Direction.Up:
                    _character.OriginAbsolute = new TE_Vector2(8, 31);
                    _character.AddAnimations(new FrameAnimation(new WalkUp(SpriteSheetPath)));
                    break;
                case Direction.Down:
                    _character.OriginAbsolute = new TE_Vector2(8, 31);
                    _character.AddAnimations(new FrameAnimation(new WalkDown(SpriteSheetPath)));
                    break;
                case Direction.Left:
                    _character.OriginAbsolute = new TE_Vector2(8, 31);
                    _character.AddAnimations(new FrameAnimation(new WalkLeft(SpriteSheetPath)));
                    break;
                case Direction.Right:
                    _character.OriginAbsolute = new TE_Vector2(8, 31);
                    _character.AddAnimations(new FrameAnimation(new WalkRight(SpriteSheetPath)));
                    break;
            }
        }
    }
}
